//
//  CountingSystemController.m
//  blackjack
//
//  Created by Thi Nguyen Tran on 3/17/10.
//  Copyright 2010 Epsilon. All rights reserved.
//

#import "CountingSystemController.h"
#import "OmegaIISystem.h"
#import "HiLoSystem.h"
#import "HiOptISystem.h"
#import "HiOptIISystem.h"
#import "KOSystem.h"

@implementation CountingSystemController

- (id)init {
	self = [super init];
	if(self) {		
		
		NSMutableArray* viewControllers = [[NSMutableArray alloc] init];
		
		UIViewController *viewController;
		CGRect frame = self.view.frame;
		frame.size.height -= self.tabBar.frame.size.height;
		
		viewController = [[KOSystem alloc] init];
		viewController.view.frame = frame;
		//viewController.tabBarItem.image = [UIImage imageNamed:@""];
		[viewControllers addObject:viewController];
		[viewController release];
		
		viewController = [[HiLoSystem alloc] init];
		viewController.view.frame = frame;
		//viewController.tabBarItem.image = [UIImage imageNamed:@""];
		[viewControllers addObject:viewController];
		[viewController release];
		
		viewController = [[HiOptISystem alloc] init];
		viewController.view.frame = frame;
		//viewController.tabBarItem.image = [UIImage imageNamed:@""];
		[viewControllers addObject:viewController];
		[viewController release];
		
		viewController = [[HiOptIISystem alloc] init];
		viewController.view.frame = frame;
		//viewController.tabBarItem.image = [UIImage imageNamed:@""];
		[viewControllers addObject:viewController];
		[viewController release];
		
		viewController = [[OmegaIISystem alloc] init];
		viewController.view.frame = frame;
		//viewController.tabBarItem.image = [UIImage imageNamed:@""];
		[viewControllers addObject:viewController];
		[viewController release];
		
		// Add them as children of the tab bar controller
		self.viewControllers = viewControllers;
		[viewControllers release];
	}
	return self;
}

- (void)tabBar:(UITabBar *)tabBar 
 didSelectItem:(UITabBarItem *)item 

{
	for(int i=0;i<self.viewControllers.count;i++) {
		if(item.title == [[self.viewControllers objectAtIndex:i] title]) {
			self.selectedViewController = nil;
			self.selectedIndex = 0;
		}
	}
}

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}


@end
